package com.haungg.base;
import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

/**  
 * Filename:    BaseDao.java
 * Description: 数据操作基础类，注入hibernateTemplate
 * Company:     
 * @author:     
 * @version:    1.0
 * Create at:   May 10, 2011 2:50:47 PM
 * modified:    
 */
@Repository
public class BaseDao implements DaoAble{
	@Autowired
	private HibernateTemplate hibernateTemplate;

	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
	
	public <T extends BasePO> void save(T t) {
		hibernateTemplate.save(t);
	}

	public <T extends BasePO> List<T> find(String queryString) {
		@SuppressWarnings("unchecked")
		List<T> list = hibernateTemplate.find(queryString);
		return list;
	}

	public <T extends BasePO> T get(Class<T> clazz, Serializable id) {
		T t = hibernateTemplate.get(clazz, id);
		return t;
	}

	public <T extends BasePO> T load(Class<T> clazz, Serializable id) {
		T t = hibernateTemplate.load(clazz, id);
		return t;
	}

}
